package com.itguigu.rabbitmq.eight;

import com.itguigu.rabbitmq.utils.RabbitMqutil;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeoutException;

/**
 * @Date 2021/7/19 10:27
 * @Created by wangle
 * @Description 死信队列-生产者
 */
public class Producer {
    public static final String exchangeName = "normal_exchange";

    public static void main(String[] args) throws IOException, TimeoutException {

        Channel channel = RabbitMqutil.getChannel();
        //发送死信消息，设置ttl时长
//        AMQP.BasicProperties  properties=new AMQP.BasicProperties.Builder().expiration("10000").build();

        for (int i = 0; i < 10; i++) {

            String message = "info" + i;
            channel.basicPublish(exchangeName, "zhangsan", null, message.getBytes(StandardCharsets.UTF_8));

            //channel.basicPublish(exchangeName,"zhangsan",properties,message.getBytes(StandardCharsets.UTF_8));
        }

    }


}
